package Messages;
import DataObjects.User;

/**   
 * This message purpose is to give back all the user's details when he logs on
 * @author Andrey
 * @author Igor
 *
 */
public class MessageLoginReply extends Message {

	private static final long serialVersionUID = 1L;

	public enum LoginStatus 
	{
	    LOGGED_IN,
	    LOGIN_FAIL
	}

	
	
	public enum ErrMsg
	{
		SUCCESS,
		INCORRECT,
		ALREADY_LOGIN,
		UNKNOWN, 
		STATUS_PROBLEMM,
	    EmployeeId_PROBLEMM		            
	}
	
	private LoginStatus status;
	private ErrMsg error;
	private User user;
	
	
	public String[] ErrMsg={"Success","Username Or Password are incorrect","You are already logged in to the system","UNKNOWN"};
	 

	public MessageLoginReply(LoginStatus stat ,ErrMsg Err,User u ) 
	{  
		super(Message.MessageType.MESSAGE_LOGIN_REPLY);
		status = stat;
		error=Err;
		user=u;		
	}
	
	
	
	
	/**
	 * 
	 * @return status
	 */
	public LoginStatus getLoginStatus ()
	{
		return status;
	}
	


	
	/**
	 * 
	 * @param n index to get an Error message
	 * @return Error Message (String)
	 */
	public String GetErrorMesage(int n)
	{
		switch (error){
		case SUCCESS :
		{
			return ErrMsg[n];
		}	
		
		case INCORRECT:
		{
			return ErrMsg[n];
		}
		
		case ALREADY_LOGIN:
		{
			return ErrMsg[n];
		}
 
		default:
			return ErrMsg[n];
		}
	}
	
 
	
	/**
	 * 
	 * @return user
	 */
	public User getUser()
	{
		return this.user;
	}
	

	/**
	 * 
	 * @return Error message
	 */
	public ErrMsg getError()
	{
		return error;
	}
	
	
}